import Vue from 'vue'
import App from './App'
import './uni.promisify.adaptor'

Vue.config.productionTip = false

Vue.prototype.$domain = {
  data: 'http://localhost:8899',
  media: 'http://localhost:8899'
}

// 全局验证token不合法提示跳转登录
Vue.prototype.$checkStatus = function (status, msg) {
  const flag = typeof msg === 'undefined'
  // console.log('全局', status)
  switch (status) {
    case 401:
      // console.log('无权限')
      uni.showModal({
        title: '提示',
        content: '您暂未登录，是否跳转登录？',
        success: function (res) {
          if (res.confirm) {
            uni.reLaunch({ url: '/pages/login/index' })
          }
        }
      })
      break
    case 222:
      uni.showToast({
        icon: 'none',
        title: msg
      })
      break
    default:
      uni.showToast({
        icon: 'none',
        title: flag ? '服务器出错' : msg
      })
      break
  }
}

App.mpType = 'app'

const app = new Vue({
  ...App
})
app.$mount()
